package com.shanzmoo.admin.web;

import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.core.cache.CurrentUserCache;
import com.shanzmoo.db.picture.entity.MallBannerPictureEntity;
import com.shanzmoo.db.picture.service.IMallBannerPictureService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商城banner图 前端控制器
 * </p>
 *
 * @author Xueqz
 * @since 2020-12-20
 */
@RestController
@RequestMapping("/api/picture/mallBanner")
public class MallBannerPictureController {

    @Autowired
    private IMallBannerPictureService mallBannerPictureService;

    @ApiOperation("首页banner图")
    @GetMapping("banner")
    public SHttpResponse<List<MallBannerPictureEntity>> getBannerList() {
        List<MallBannerPictureEntity> list = mallBannerPictureService.getBannerList();
        return SHttpResponse.ok(list);
    }

    @ApiOperation("添加banner图")
    @PostMapping("addBanner")
    public SHttpResponse<List<MallBannerPictureEntity>> addBanner(@RequestBody MallBannerPictureEntity saveDTO) {
        saveDTO.setCreateUser(CurrentUserCache.getUserId());
        mallBannerPictureService.addBanner(saveDTO);
        List<MallBannerPictureEntity> list = mallBannerPictureService.getBannerList();
        return SHttpResponse.ok(list);
    }


}
